/******************************************************************************/
/* usb_descr.h                                                                */
/******************************************************************************/

#ifndef __USB_DESCR_H
#define __USB_DESCR_H


/*********************** Constants for USB DESCR ******************************/
#define USB_STR_DESCR_LANGID    (0)
#define USB_STR_DESCR_VID       (1)
#define USB_STR_DESCR_PID       (2)
#define USB_STR_DESCR_SN        (3)


#pragma pack(1)
//==============================================================================
//  Class USB_DEV_DESCR
//==============================================================================
class USB_DEV_DESCR
{
    //==========================================================================
    // App: Constructor
    //==========================================================================
    public: USB_DEV_DESCR(uint16_t BCDUSB,
                          __eUSB_DEVICE_CLASS eDEVCLASS,
                          uint8_t DEVSUBCLASS,
                          uint8_t DEVPRTCL,
                          uint8_t MAXPACKSIZE0,
                          uint16_t IDVENDOR,
                          uint16_t IDPRODUCT,
                          uint16_t BCDDEV,
                          uint8_t IMANUFSTR,
                          uint8_t IPRODUCTSTR,
                          uint8_t ISERNUMSTR,
                          uint8_t NUMCFG)
                          : bLength(sizeof(USB_DEV_DESCR)),
                            bDescriptorType(eUSB_DEV_DESCR),
                            bcdUSB(BCDUSB),
                            bDeviceClass(eDEVCLASS),
                            bDeviceSubClass(DEVSUBCLASS),
                            bDeviceProtocol(DEVPRTCL),
                            bMaxPacketSize0(MAXPACKSIZE0),
                            idVendor(IDVENDOR),
                            idProduct(IDPRODUCT),
                            bcdDevice(BCDDEV),
                            iManufacturer(IMANUFSTR),
                            iProduct(IPRODUCTSTR),
                            iSerialNumber(ISERNUMSTR),
                            bNumConfigurations(NUMCFG) {};
    //==========================================================================
    //==========================================================================

    public: const uint8_t bLength;
    public: const __eUSB_DESCRIPTOR_TYPE bDescriptorType;
    public: const uint16_t bcdUSB;
    public: const __eUSB_DEVICE_CLASS bDeviceClass;
    public: const uint8_t bDeviceSubClass;
    public: const uint8_t bDeviceProtocol;
    public: const uint8_t bMaxPacketSize0;
    public: const uint16_t idVendor;
    public: const uint16_t idProduct;
    public: const uint16_t bcdDevice;
    public: const uint8_t iManufacturer;
    public: const uint8_t iProduct;
    public: const uint8_t iSerialNumber;
    public: const uint8_t bNumConfigurations;
};
//==============================================================================
//==============================================================================


//==============================================================================
//  Class USB_DEV_QUALIFIER_DESCR
//==============================================================================
class USB_DEV_QUALIFIER_DESCR
{
    //==========================================================================
    // App: Constructor
    //==========================================================================
    public: USB_DEV_QUALIFIER_DESCR(uint16_t BCDUSB,
                                    __eUSB_DEVICE_CLASS eDEVCLASS,
                                    uint8_t DEVSUBCLASS,
                                    uint8_t DEVPRTCL,
                                    uint8_t MAXPACKSIZE0,
                                    uint8_t NUMCFG)
                                    : bLength(sizeof(USB_DEV_QUALIFIER_DESCR)),
                                      bDescriptorType(eUSB_DEV_QUALIFIER_DESCR),
                                      bReserved(0),
                                      bcdUSB(BCDUSB),
                                      bDeviceClass(eDEVCLASS),
                                      bDeviceSubClass(DEVSUBCLASS),
                                      bDeviceProtocol(DEVPRTCL),
                                      bMaxPacketSize0(MAXPACKSIZE0),
                                      bNumConfigurations(NUMCFG) {};
    //==========================================================================
    //==========================================================================

    public: const uint8_t bLength;
    public: const __eUSB_DESCRIPTOR_TYPE bDescriptorType;
    public: const uint16_t bcdUSB;
    public: const __eUSB_DEVICE_CLASS bDeviceClass;
    public: const uint8_t bDeviceSubClass;
    public: const uint8_t bDeviceProtocol;
    public: const uint8_t bMaxPacketSize0;
    public: const uint8_t bNumConfigurations;
    public: const uint8_t bReserved;
};
//==============================================================================
//==============================================================================


//==============================================================================
//  Class USB_CFG_DESCR
//==============================================================================
class USB_CFG_DESCR
{
    //==========================================================================
    // App: Constructor
    //==========================================================================
    public: USB_CFG_DESCR(uint16_t TLEN,
                          uint8_t NUMIF,
                          uint8_t CFGVAL,
                          uint8_t ICFG,
                          uint8_t MATTR,
                          uint8_t MAXPWR)
                          : bLength(sizeof(USB_CFG_DESCR)),
                            bDescriptorType(eUSB_CFG_DESCR),
                            wTotalLength(TLEN),
                            bNumInterfaces(NUMIF),
                            bConfigurationValue(CFGVAL),
                            iConfiguration(ICFG),
                            bmAttributes(MATTR),
                            bMaxPower(MAXPWR) {};
    //==========================================================================
    //==========================================================================

    public: const uint8_t bLength;
    public: const __eUSB_DESCRIPTOR_TYPE bDescriptorType;
    public: const uint16_t wTotalLength;
    public: const uint8_t bNumInterfaces;
    public: const uint8_t bConfigurationValue;
    public: const uint8_t iConfiguration;
    public: const uint8_t bmAttributes;
    public: const uint8_t bMaxPower;
};
//==============================================================================
//==============================================================================


//==============================================================================
//  Class USB_IF_DESCR
//==============================================================================
class USB_IF_DESCR
{
    //==========================================================================
    // App: Constructor
    //==========================================================================
    public: USB_IF_DESCR(uint8_t IFNUM,
                         uint8_t ALTSETT,
                         uint8_t NUMEP,
                         uint8_t IFCLASS,
                         uint8_t IFSUBCLASS,
                         uint8_t IFPRTCL,uint8_t IIF)
                         : bLength(sizeof(USB_IF_DESCR)),
                           bDescriptorType(eUSB_IF_DESCR),
                           bInterfaceNumber(IFNUM),
                           bAlternateSetting(ALTSETT),
                           bNumEndpoints(NUMEP),
                           bInterfaceClass(IFCLASS),
                           bInterfaceSubClass(IFSUBCLASS),
                           bInterfaceProtocol(IFPRTCL),
                           iInterface(IIF) {};
    //==========================================================================
    //==========================================================================

    public: const uint8_t bLength;
    public: const __eUSB_DESCRIPTOR_TYPE bDescriptorType;
    public: const uint8_t bInterfaceNumber;
    public: const uint8_t bAlternateSetting;
    public: const uint8_t bNumEndpoints;
    public: const uint8_t bInterfaceClass;
    public: const uint8_t bInterfaceSubClass;
    public: const uint8_t bInterfaceProtocol;
    public: const uint8_t iInterface;
};
//==============================================================================
//==============================================================================


//==============================================================================
//  Class USB_EP_DESCR
//==============================================================================
class USB_EP_DESCR
{
    //==========================================================================
    // App: Constructor
    //==========================================================================
    public: USB_EP_DESCR(uint8_t EPADDR,
                         uint8_t ATTR,
                         uint16_t MAXPACKSIZE,
                         uint8_t INTERVAL)
                         : bLength(sizeof(USB_EP_DESCR)),
                           bDescriptorType(eUSB_EP_DESCR),
                           bEndpointAddress(EPADDR),
                           bmAttributes(ATTR),
                           wMaxPacketSize(MAXPACKSIZE),
                           bInterval(INTERVAL) {};
    //==========================================================================
    //==========================================================================

    public: const uint8_t bLength;
    public: const __eUSB_DESCRIPTOR_TYPE bDescriptorType;
    public: const uint8_t bEndpointAddress;
    public: const uint8_t bmAttributes;
    public: const uint16_t wMaxPacketSize;
    public: const uint8_t bInterval;
};
//==============================================================================
//==============================================================================


/********************* CDC Class-Specific Descriptors *************************/
//==============================================================================
//  Class CDC_HEADER_FUNC_DESCR
//==============================================================================
class CDC_HEADER_FUNC_DESCR
{
    //==========================================================================
    // App: Constructor
    //==========================================================================
    public: CDC_HEADER_FUNC_DESCR() : bFunctionLength(sizeof(CDC_HEADER_FUNC_DESCR)),
                                      bDescriptorType(CS_INTERFACE),
                                      bDescriptorSubType(HEADER_FUNC_DESCR),
                                      bcdCDC(BCD_USB1) {};
    //==========================================================================
    //==========================================================================

    public: const uint8_t bFunctionLength;
    public: const uint8_t bDescriptorType;
    public: const uint8_t bDescriptorSubType;
    public: const uint16_t bcdCDC;
};
//==============================================================================
//==============================================================================


//==============================================================================
//  Class CDC_ABSTRACT_CTRL_FUNC_DESCR
//==============================================================================
class CDC_ABSTRACT_CTRL_FUNC_DESCR
{
    //==========================================================================
    // App: Constructor
    //==========================================================================
    public: CDC_ABSTRACT_CTRL_FUNC_DESCR() : bFunctionLength(sizeof(CDC_ABSTRACT_CTRL_FUNC_DESCR)),
                                             bDescriptorType(CS_INTERFACE),
                                             bDescriptorSubType(ABSTR_CTRL_FUNC_DESCR),
                                             bCapabilities(0x02) {};
    //==========================================================================
    //==========================================================================

    public: const uint8_t bFunctionLength;
    public: const uint8_t bDescriptorType;
    public: const uint8_t bDescriptorSubType;
    public: const uint8_t bCapabilities;
};
//==============================================================================
//==============================================================================


//==============================================================================
//  Class CDC_UNION_FUNC_DESCR
//==============================================================================
class CDC_UNION_FUNC_DESCR
{
    //==========================================================================
    // App: Constructor
    //==========================================================================
    public: CDC_UNION_FUNC_DESCR() : bFunctionLength(sizeof(CDC_UNION_FUNC_DESCR)),
                                     bDescriptorType(CS_INTERFACE),
                                     bDescriptorSubType(UNION_FUNC_DESCR),
                                     bMasterInterface(CDC_COMM_INTF_ID),
                                     bSlaveInterface(CDC_DATA_INTF_ID) {};
    //==========================================================================
    //==========================================================================

    public: const uint8_t bFunctionLength;
    public: const uint8_t bDescriptorType;
    public: const uint8_t bDescriptorSubType;
    public: const uint8_t bMasterInterface;
    public: const uint8_t bSlaveInterface;
};
//==============================================================================
//==============================================================================


//==============================================================================
//  Class CDC_CALL_MGT_FUNC_DESCR
//==============================================================================
class CDC_CALL_MGT_FUNC_DESCR
{
    //==========================================================================
    // App: Constructor
    //==========================================================================
    public: CDC_CALL_MGT_FUNC_DESCR() : bFunctionLength(sizeof(CDC_CALL_MGT_FUNC_DESCR)),
                                       bDescriptorType(CS_INTERFACE),
                                       bDescriptorSubType(CALL_MGT_FUNC_DESCR),
                                       bCapabilities(0x00),
                                       bDataIfId(CDC_DATA_INTF_ID) {};
    //==========================================================================
    //==========================================================================

    public: const uint8_t bFunctionLength;
    public: const uint8_t bDescriptorType;
    public: const uint8_t bDescriptorSubType;
    public: const uint8_t bCapabilities;
    public: const uint8_t bDataIfId;
};
//==============================================================================
//==============================================================================


#pragma pack()


#endif